// Appendix Table 2: 	
	use "$dir\DataSCLB", clear
	
		global students	BL_P1_w0 miss_BL male Age 
		global teachers TeachMale Teach_Age Teach_Exper Teach_Years_Schooling
		global schools overall_enrollment_total pupil_teacher_ratio_overall plepass_rate overall_number_of_teachers
		global schools_extra no_of_desks c_compound vc_compound nursery repeat miss_school teach_miss home_fees staff_room Sanitation Information Access_to_books Home_conditions Caning
		
		gen empty = 0
		label var BL_P1_w0 "Baseline Score Index"
		gen names = ""
		local i = 1
		mat est = J(1,6,.)
		foreach var in empty $students empty $teachers empty $schools $schools_extra {
			// Regression
			areg `var' MT_Program CCT_Program, a(Group_detailed) cluster(School_blind)   
			// Create values
			mat b= e(b)
			mat V = e(V)
			local N = e(df_r)
			local t_MT  = abs((b[1,1])/(V[1,1]^0.5))
			local t_CCT = abs((b[1,2])/(V[2,2]^0.5))
			local F = Ftail(2,`N',e(F))
			mat a = b[1,3],(b[1,3]+b[1,2]),(b[1,1]+b[1,3]),ttail(`N',`t_MT')*2,ttail(`N',`t_CCT')*2,`F'
			mat est = est\a
			// Variable Name
			local varlab: variable label `var'
			replace names = "`varlab'" in `i'
			local i = `i'+1
		}
		mat est = est[2..`i',1..6]
		svmat est, name(table_)
		br names table_*
		format table_1-table_3 %12.2f
		format table_4-table_6 %12.3f
		local i = `i'-1
		// Edit the table
			replace names = subinstr(names,"%","\%",.)
			gen aux = "$^\dagger$" in 12/15
			replace names = names + aux 
			gen panels = "", before(names)
			gen i = _n if names!=""
			replace panels = "\multicolumn{2}{l}{\textit{Student Variables}}" in 1
			replace panels = "\multicolumn{2}{l}{\textit{Teacher Variables}}" in 6
			replace panels = "\multicolumn{2}{l}{\textit{School Variables}}" in 11
			replace names  = "\quad " + names if names!=""
			
			drop aux i
			
			
	save "$output/AppendixTable2.dta", replace